import Vue from "vue";
import VueRouter from 'vue-router';
Vue.use(VueRouter);

const routes=[
  {
    path:'/',component:require('../components/modules/index.vue')
  },{
  	name:'list',path:'/list',
  	component:require('../components/modules/list.vue'),
  	meta: { requiresAuth: true },//$route.meta 获取
  	children:[
  		{
  			name:'list_show',path:'show/:userId',
        component (resolve){
          require.ensure(['../components/modules/show.vue'],()=>{
            resolve(require('../components/modules/show.vue'))
          })
        }
  		}
  	]
  },
  {
  	name:'show',path:'/show/:userId',component:require('../components/modules/show.vue')
  },{
  	path:'/router',
  	components:{//多个路由
  		default:require('../components/modules/list.vue'),
  		rv:require('../components/modules/show.vue')
  	}
  },{
		name:'login',path:'/login',component:require('../components/modules/login.vue')
	}
];

export default new VueRouter({
	mode: 'history',
    scrollBehavior: () => ({ y: 0 }),
    routes:routes
})